//
//  MHCircleManageController.m
//  MiaoCircle
//
//  Created by 许正荣 on 2018/4/20.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHCircleManageViewController.h"
#import "MHCircleManageViewModel.h"
#import "MHCommonCell.h"
@interface MHCircleManageViewController ()
@property (nonatomic, readonly, strong) MHCircleManageViewModel *viewModel;
@end

@implementation MHCircleManageViewController
@dynamic viewModel;
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    //self.view.userInteractionEnabled  =  [self.viewModel.circleInfo currentUserIsOwner];
    // Do any additional setup after loading the view.
    if (![self.viewModel.circleInfo currentUserIsOwner]) {
        self.navigationItem.titleView = createAttriNavTitleLable(@"圈子管理", @"仅圈主可设置");
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)configureCell:(MHCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object
{
   
    if (indexPath.section == 2 ) {
        cell.userInteractionEnabled = YES;
    }else
    {
        MHCommonArrowItemViewModel *item = object;
        
        if ([item.title isEqualToString:@"圈子活动"]) {
            cell.userInteractionEnabled = YES;
        }else
        {
            cell.userInteractionEnabled =  [self.viewModel.circleInfo currentUserIsOwner];
        }
        
    }
    [cell bindViewModel:object];
}

- (void)bindViewModel{
    [super bindViewModel];
    @weakify(self);
    /// show HUD
    //    [[self.viewModel.exitCircle.executing
    //      skip:1]
    //     subscribeNext:^(NSNumber * showHud) {
    //         if (showHud.boolValue) {
    //             [MBProgressHUD mh_showProgressHUD:@"正在退出..."];
    //         }else{
    //             [MBProgressHUD mh_hideHUD];
    //         }
    //     }];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    if ([self.viewModel.circleInfo currentUserIsOwner]) {
        [self.viewModel.updateInfoCommand execute:nil];
    }
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
